<div class="conter_box box_weixin">
    <div class="bt-form">
        <div class="line">
            <span class="tname">Notify everyone</span>
            <div class="info-r" style="height:28px; margin-left:125px">
                <input class="btswitch btswitch-ios" id="panel_alert_all" type="checkbox" disabled="disabled" checked>
                <label style="position: relative;top: 5px;" title="Only supports notify everyone." class="btswitch-btn" for="panel_alert_all"></label>
            </div>
        </div>
        <div class="line">
            <span class="tname">WeCom URL</span>
            <div class="info-r">
                <textarea name="channel_weixin_value" class="bt-input-text mr5" type="text" placeholder="Please enter WeCom url" style="width: 300px; height:90px; line-height:20px"></textarea>
            </div>
            <button class="btn btn-success btn-sm weixin_submit" style="margin: 10px 0 0 125px;">Save</button>
        </div>
        <div class="line">
            <ul class="help-info-text c7">
                <li>Notify everyone, Immutable</li>
            </ul>
        </div>
    </div>
</div>

<!--微信模块-->
<script type="text/javascript">
    var weixin = {
        all_info: {},
        init: function () {
            this.all_info = $('.alarm-view .bt-w-menu p.bgw').data('data'); //设置全局数据
            this.get_weixin_data();
        },
        /**
            *@description 获取微信url，保存按钮添加事件
        */
        get_weixin_data: function () {
            var that = this;

            if (weixin.all_info['data']) {
                $('textarea[name=channel_weixin_value]').val(weixin.all_info['data']['weixin_url']);
            }
            // 微信信息设置
            $('.weixin_submit').click(function () {
                that.set_submit_ding();
            })
        },
        /**
            *@description 设置微信url信息，保存按钮
        */
        set_submit_ding: function () {
            var that = this;

            var _url = $('textarea[name=channel_weixin_value]').val();
            if (_url == '') return layer.msg('Please enter WeCom url', { icon: 2 })
            var loadT = layer.msg('WeCom is being set up, please wait...', { icon: 16, time: 0, shade: [0.3, '#000'] });
            $.post('/config?action=set_msg_config&name=weixin', { url: _url, atall: 'True' }, function (rdata) {
                layer.close(loadT);
                layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 })
                if (rdata.status) that.refresh_data();
            })
        },
        refresh_data: function () {
            var that = this
            $.post('/config?action=get_msg_configs', function (rdata) {
                $.each(rdata, function (index, item) {
                    if (item.name == that.all_info.name) {
                        $('.alarm-view .bt-w-menu p.bgw').data('data', item)
                        // that.init()
                    }
                });
            })
        }
    }

</script>